Applications running in the crust can
(directly or indirectly)
invoke the services from the Mantle via the RISC-V ecall instruction.
To do this, input parameters are loaded into CPU registers
a0 through a6.
The particular service number is then loaded into a7,
and the ecall instruction issued.
When the service has been performed,
any results will be returned via a0 through a2.
(As of this writing,
no system call returns any values in a3 through a6.)
Unless otherwise documented,
registers not used for return values retain their previous value.
NOTE. The ECALL numbers in this list were compiled 2026 April 28. The Mantle software is still in flux! Always double-check the actual sources for current values.
Returns from an event handler up-call from the Mantle.
Event handlers,
also known as event procedures or *EvProc*s,
are invoked with three parameters.
Register a0 holds the event type.
Register a1 holds a timestamp, providing an indication of when the event happened.
Register a2 holds a dword which is unique to the kind of event being processed.
To return from an event handler,
the application issues an ecNextEvent ecall.
Depending upon the nature of the event handler,
return values may be provided in registers a0-a2.
Unless documented otherwise,
unhandled events should always return with a0 set to zero.
See also ecSetEvProcPC and ecSetEvProcSP.
Exits the application and the Kestrel-2/EX emulator.
Register a0 contains the POSIX-style result code.
Writes a single byte to the operator's console. For the Kestrel-2/EX emulator, this will print a character to the host OS interface that launched the emulator. It will not print a character to the Kestrel's screen.
Register A0 holds the character to print. Only bits 7..0 are significant; bits 63..8 are ignored and should be zero for future compatibility.
Upon completion, register A0 will hold either 0 or 1, indicating if the character failed to print, or succeeded, respectively.
Writes an entire buffer out to the operator's console. For the Kestrel-2/EX emulator, this will print a character to the host OS interface that launched the emulator. It will not print a character to the Kestrel's screen.
Register A0 holds the starting address of the buffer to print. Register A1 holds the size of the buffer.
Upon completion, register A0 will hold the total number of bytes written, which may potentially be less than that specified in A2.
NOTE: due to a bug in the current version of Mantle, the buffer must lie on an even address.
Writes an entire buffer out to the operator's console. For the Kestrel-2/EX emulator, this will print a character to the host OS interface that launched the emulator. It will not print a character to the Kestrel's screen.
Register A0 holds the starting address of the buffer to print.
The buffer must be terminated by a zero-valued byte
(hence the Z in ecConTypeZ).
Upon completion, register A0 will be undefined.
NOTE: due to a bug in the current version of Mantle, the buffer must lie on an even address.